import { connect } from 'dva';
import ProductList from '../components/ProductList';

const Products = ({ dispatch, products }) => {
  debugger
  function handleDelete(id) {
    dispatch({
      type: 'products/delete',
      payload: id,
    });
  }
  return (
    <div>
      <h2>List of Products</h2>
      <ProductList onDelete={handleDelete} products={products} />
    </div>
  );
};

// let mapping = ({ products }) => ({ products });

let mapping = ({products}) => {
  debugger
  products.desc="mapping";
  return {products}
};

let connetcting = connect(mapping);

export default connetcting(Products);
